#include "object.h"
#include <cmath>
#include <SDL/SDL.h>
#include <sstream>
#include <string>

using namespace std;

int ObjectDistance(CObject t1, CObject t2) {
    int x1 = t1.GetX();
    int x2 = t2.GetX();
    int y1 = t1.GetY();
    int y2 = t2.GetY();

    int x = abs(x2-x1);
    int y = abs(y2-y1);

    return x*x+y*y;
}

void BlitSurface(int wx, int wy, SDL_Surface *what, SDL_Surface *where) {
    SDL_Rect rect;
    rect.x = wx;
    rect.y = wy;

    SDL_BlitSurface(what,NULL,where,&rect);
}

SDL_Surface *RenderText(TTF_Font *font, const char *text) {
    SDL_Color bielafarba = {255,255,255};
    return TTF_RenderText_Solid(font,text,bielafarba);
}

SDL_Surface *RenderText(TTF_Font *font, int text) {
    SDL_Color bielafarba = {255,255,255};
    stringstream ss;
    ss << text;
    return TTF_RenderText_Solid(font,ss.str().c_str(),bielafarba);
}
